package com.peng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peng.pojo.Grade;
import com.peng.service.GradeService;
import com.peng.mapper.GradeMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author dell
* @description 针对表【tb_grade】的数据库操作Service实现
* @createDate 2022-05-15 13:39:17
*/
@Service
public class GradeServiceImpl extends ServiceImpl<GradeMapper, Grade> implements GradeService{

    @Override
    public IPage<Grade> getGrades(Integer pageNo, Integer pageSize, String gradeName) {
        Page<Grade> page = new Page<>(pageNo,pageSize);
        LambdaQueryWrapper<Grade> wrapper = new LambdaQueryWrapper<>();
        if (!StringUtils.isEmpty(gradeName))
            wrapper.like(Grade::getName,gradeName);
        wrapper.orderByAsc(Grade::getId);
        return baseMapper.selectPage(page,wrapper);
    }
}




